import type { FunctionalComponent } from 'vue'

/**
 * 用作页面刷新体验
 * ```typescript
 * {
    path: '/:path(.*)*',
    name: 'NotFound',
    component: () => import('@/component-tsx/ViewRefresh')
  }
 * ```
 * @returns
 */
export const ViewRefresh: FunctionalComponent = () => {
  const router = useRouter()
  const { params, query } = useRoute()
  const path = params?.path || ''
  onMounted(() => {
    router.replace({
      path: `/${path}`,
      query,
    })
  })
  return <></>
}
